home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / vb_term2 / tty.frm < prev    next >
Text File  |  1995-09-06  |  5KB  |  232 lines

  1. VERSION 2.00
  2. Begin Form TTY 
  3.    BackColor       =   &H00FFFFFF&
  4.    BorderStyle     =   0  'None
  5.    Caption         =   "Terminal"
  6.    ClientHeight    =   405
  7.    ClientLeft      =   1050
  8.    ClientTop       =   2160
  9.    ClientWidth     =   4365
  10.    FontBold        =   0   'False
  11.    FontItalic      =   0   'False
  12.    FontName        =   "Courier"
  13.    FontSize        =   9.75
  14.    FontStrikethru  =   0   'False
  15.    FontTransparent =   0   'False
  16.    FontUnderline   =   0   'False
  17.    ForeColor       =   &H00000000&
  18.    Height          =   1095
  19.    Icon            =   TTY.FRX:0000
  20.    Left            =   990
  21.    LinkMode        =   1  'Source
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   27
  24.    ScaleMode       =   3  'Pixel
  25.    ScaleWidth      =   291
  26.    Top             =   1530
  27.    Width           =   4485
  28.    Begin Menu file 
  29.       Caption         =   "&File"
  30.       Begin Menu mcexit 
  31.          Caption         =   "&Exit"
  32.          Shortcut        =   ^X
  33.       End
  34.    End
  35.    Begin Menu settings 
  36.       Caption         =   "&Settings"
  37.       Begin Menu comparams 
  38.          Caption         =   "&Com Params"
  39.       End
  40.    End
  41.    Begin Menu transfers 
  42.       Caption         =   "&Transfers"
  43.       Begin Menu capture 
  44.          Caption         =   "&Capture to file ..."
  45.          Shortcut        =   ^C
  46.       End
  47.    End
  48. End
  49. Sub capture_Click ()
  50.  
  51.     If (FlagCapture = 0) Then
  52.         opencapture.Show 1
  53.     Else
  54.         Close #FlagCapture
  55.         FlagCapture = 0
  56.         capture.caption = "Capture to file ..."
  57.     End If
  58.  
  59. End Sub
  60.  
  61. Sub CloseCom ()
  62.  
  63.     Dim x As Integer
  64.     x = SerialClose()
  65.  
  66.     If (x < 0) Then
  67.         MsgBox "Close Error"
  68.     Else
  69.         MsgBox "Closed"
  70.     End If
  71.  
  72. End Sub
  73.  
  74. Sub comparams_Click ()
  75.  
  76.     Call ConfigCom
  77.  
  78. End Sub
  79.  
  80. Sub ConfigCom ()
  81.     Call hide_cursor
  82.     mousepointer = 11
  83.  
  84.     TConfigChanged = 0
  85.  
  86.     config.Show 1
  87.     
  88.     x% = DoEvents()         ' Force Screen Update
  89.  
  90.  
  91.     If (TConfigChanged <> 0) Then
  92.         x% = SerialClose()
  93.         x% = SerialOpen(TPort)
  94.         x% = SerialConfig(TBaud, TWord, TParity)
  95.     End If
  96.  
  97.     mousepointer = 0
  98.  
  99.     Call disp_cursor
  100. End Sub
  101.  
  102. Sub Form_KeyDown (KeyCode As Integer, Shift As Integer)
  103.  
  104.     '------------------------------------------------------------------------
  105.     '   Form_KeyDown
  106.     '
  107.     '   intercepts keys which do not generate an ANSI code, such as the
  108.     '   function and cursor movement keys, and translates them into VT100
  109.     '   style kepresses which are transmitted to the Form_Keypress()
  110.     '   event, which deals with transmitting keystrokes.  It could
  111.     '   alternatively transmit keystrokes directly.
  112.     '------------------------------------------------------------------------
  113.     
  114.     buf$ = ""
  115.  
  116.     Select Case KeyCode
  117.         Case KEY_LEFT
  118.             buf$ = "[D"
  119.  
  120. '        Case KEY_END
  121. '            buf$ = ""
  122.  
  123.         Case KEY_HOME
  124.             buf$ = "[H"
  125.  
  126.         Case KEY_UP
  127.             buf$ = "[A"
  128.  
  129.         Case KEY_RIGHT
  130.             buf$ = "[C"
  131.  
  132.         Case KEY_DOWN
  133.             buf$ = "[B"
  134.  
  135. '        Case KEY_INSERT
  136. '            buf$ = ""
  137.  
  138. '        Case KEY_DELETE
  139. '            buf$ = ""
  140.  
  141.         Case Else
  142.             Exit Sub
  143.  
  144.     End Select
  145.  
  146.     buf$ = Chr$(27) + buf$
  147.     r% = SerialWrite(buf$)
  148.  
  149. End Sub
  150.  
  151. Sub form_KeyPress (KeyAscii As Integer)
  152.  
  153.     r% = SerialWrite(Chr$(KeyAscii))
  154.     
  155. End Sub
  156.  
  157. Sub Form_Load ()
  158.     mousepointer = 11
  159.  
  160.     tty.scalemode = 1
  161.     tty.height = (tty.height - tty.scaleheight) + 24.25 * tty.TextHeight("M")
  162.     tty.width = (tty.width - tty.scalewidth) + 80 * tty.TextWidth("M")
  163.     tty.top = 0
  164.     tty.left = (screen.width - tty.width) / 2
  165.     tty.scalemode = 3
  166.     tty.Show
  167.     Call term_init
  168.  
  169.     config.Show 1
  170.  
  171.     r% = SerialOpen(TPort)
  172.     If (r% <> 0) Then
  173.         MsgBox "Unable to open port", 16, "VBTERM"
  174.         End
  175.     End If
  176.  
  177.     r% = SerialConfig(TBaud, TWord, TParity)
  178.     If (r% <> 0) Then
  179.         MsgBox "Unable to configure port", 16, "VBTERM"
  180.         End
  181.     End If
  182.  
  183.     FlagCapture = 0
  184.     mousepointer = 0
  185.  
  186.     Call ReceiveLoop
  187.  
  188. End Sub
  189.  
  190. Sub Form_Paint ()
  191.  
  192.     Call RedrawScreen
  193.  
  194. End Sub
  195.  
  196. Sub Form_Unload (Cancel As Integer)
  197.  
  198.     i% = SerialClose()
  199.     If (FlagCapture <> 0) Then Close #FlagCapture
  200.     End
  201. End Sub
  202.  
  203. Sub mcexit_Click ()
  204.  
  205.     Form_Unload (i%)
  206.  
  207. End Sub
  208.  
  209. Sub ReceiveLoop ()
  210.  
  211.     Dim b As String
  212.     Dim ln As Integer
  213.  
  214.     b = Space$(128)
  215.  
  216. ComPollLoop:
  217.         ln = SerialRead(b, 128)
  218.  
  219.         If ln <> 0 Then
  220.             Call term_put(b, ln)
  221.             If (FlagCapture <> 0) Then Print #FlagCapture, Left$(b, ln);
  222.         Else
  223.             Call disp_cursor
  224.         End If
  225.  
  226.         x% = DoEvents()
  227.  
  228.     GoTo ComPollLoop
  229.  
  230. End Sub
  231.  
  232.